<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>新用户注册(js 测试)</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

<script src="jquery_last.js" type="text/javascript"></script>
<link type="text/css" rel="stylesheet" href="style/validator.css"></link>
<script src="formValidator.js" type="text/javascript" charset="UTF-8"></script>
<script src="formValidatorRegex.js" type="text/javascript" charset="UTF-8"></script>
<script language="javascript" src="DateTimeMask.js" type="text/javascript"></script>

<style type="text/css" media="all">
body,div{font-size:12px;}
.divFrame{width :400px;border:solid 1px #666;font-size:10pt}
.divTitle{background-color:#eee;padding:5px}
.divContent{padding:5px;display:none}
.divCurrColor {background-color:blue}
</style>
<script type="text/javascript">
$(document).ready(function(){
	//$.formValidator.initConfig({onerror:function(){alert("校验没有通过，具体错误请看错误提示")}});
	
	$.formValidator.initConfig({formid:"form1",onerror:function(msg){alert(msg)},onsuccess:function(){alert('success');return false;}});
	$("#userName").formValidator({onshow:" ",onfocus:"用户名至少6个字符,最多10个字符",oncorrect:"该用户名可以注册"}).inputValidator({min:1,max:10,onerror:"你输入的用户名非法,请确认"}).regexValidator({regexp:"username",datatype:"enum",onerror:"用户名格式不正确"})
	    .ajaxValidator({
	    
	    type : "get",
		url : "checkUser.do",
		datatype : "json",
		success : function(data){
            if( data == "1" )
			{
                return true;
			}
            else
			{	
                return false;
			}
		},
		buttons: $("#button"),
		error: function(){alert("服务器没有返回数据，可能服务器忙，请重试");},
		onerror : "该用户名已存在，请更换用户名",
		onwait : "正在对用户名进行合法性校验，请稍候..."
	});
	$("#password1").formValidator({onshow:" ",onfocus:"密码不能为空",oncorrect:"密码合法"}).inputValidator({min:6,empty:{leftempty:false,rightempty:false,emptyerror:"密码两边不能有空符号"},onerror:"密码不能少于6位,请确认"});
	$("#password2").formValidator({onshow:" ",onfocus:"两次密码必须一致哦",oncorrect:"密码一致"}).inputValidator({min:6,empty:{leftempty:false,rightempty:false,emptyerror:"重复密码两边不能有空符号"},onerror:"重复密码不能为空,请确认"}).compareValidator({desid:"password1",operateor:"=",onerror:"2次密码不一致,请确认"});
	$("#csny").focus(function(){WdatePicker({skin:'whyGreen',oncleared:function(){$(this).blur();},onpicked:function(){$(this).blur();}})}).formValidator({onshow:"请输入的出生日期",onfocus:"请输入的出生日期，不能全部是0哦",oncorrect:"你输入的日期合法"}).inputValidator({min:"1900-01-01",max:"2000-01-01",type:"date",onerror:"日期必须在\"1900-01-01\"和\"2000-01-01\"之间"});//.defaultPassed();
	$("#sfzh").formValidator({onshow:" ",onfocus:"输入15或18位的身份证",oncorrect:"输入正确"}).functionValidator({fun:isCardID});
	$("#shouji").formValidator({onshow:" ",onfocus:"请输入你的手机号码，不可以为空哦",oncorrect:"谢谢你的合作"}).inputValidator({min:11,max:11,onerror:"手机号码必须是11位的,请确认"}).regexValidator({regexp:"mobile",datatype:"enum",onerror:"你输入的手机号码格式不正确"});;
	$("#email").formValidator({onshow:" ",onfocus:"邮箱6-100个字符,输入正确了才能离开焦点",oncorrect:"恭喜你,你输对了"}).inputValidator({min:6,max:100,onerror:"你输入的邮箱长度非法,请确认"}).regexValidator({regexp:"^([\\w-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([\\w-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$"});
	$("#csny").focus(function(){WdatePicker({skin:'whyGreen',oncleared:function(){$(this).blur();},onpicked:function(){$(this).blur();}})}).formValidator({onshow:" ",onfocus:"请输入的出生日期，不能全部是0哦",oncorrect:"你输入的日期合法"}).inputValidator({min:"1900-01-01",max:"2000-01-01",type:"date",onerror:"日期必须在\"1900-01-01\"和\"2000-01-01\"之间"});//.defaultPassed();
});


$(function(){
		$(".divTitle").click(function(){
		if($(".divContent").is(':visible')){
		$(this).next(".divContent").css("display","none");
		}else{
		$(this).next(".divContent").css("display","block");
		}
		});
});


</script>

  </head>
  <h2>jquey ajax测试</h2>
  <body> 
  <div class="divFrame">
  	<div class="divTitle" id = "testId">测试信息</div>
  	<div class="divContent">
    <form action="register.do" method="post" name="form1" id="form1">  
  <table border="0px" style="font-size:12px" width="630px">
    <tr> 
      <td align="right">用户名:</td>
      <td><input type="text" id="userName" style="width:150px"/></td>
      <td><span id="userNameTip" style="float:left"></span></td>
    </tr>
    <tr> 
      <td align="right">密码:</td>
      <td><input type="password" id="password1" style="width:150px" /></td>
      <td><div id="password1Tip" style="width:250px"></div></td>
    </tr>
    <tr> 
      <td align="right">重复密码:</td>
      <td><input type="password" id="password2" style="width:150px" /></td>
      <td><div id="password2Tip" style="width:250px"></div></td>
    </tr>
    <tr>
      <td align="right">身份证号</td>
      <td><input name="text2" type="text" id="sfzh" style="width:150px" value="" /></td>
      <td><div id="sfzhTip" style="width:250px"></div></td>
    </tr>
     <tr> 
      <td align="right">手机号码:</td>
      <td><input type="text" id="shouji" style="width:150px" /></td>
      <td><div id="shoujiTip" style="width:250px"></div></td>
    </tr>
     <tr> 
      <td align="right">出生日期:</td>
      <td><input type="text" id="csny" style="width:120px" value="1982-09-21" /></td>
      <td><div id="csnyTip" style="width:300px"></div></td>
    </tr>
    <tr> 
      <td align="right">电子邮箱:</td>
      <td><input type="text" id="email" style="width:150px" /></td>
      <td><div id="emailTip" style="width:250px"></div></td>
    </tr>
  </table>
  <br />
  <input type="submit" name="button" id="button" value="提交" />
</form>
</div>

</div>


  </body>
</html>
<script defer="defer" src="datepicker/WdatePicker.js" type="text/javascript"></script>